<?php

class ProductPhotoForm extends BaseProductPhotoForm
{

    public function configure()
    {
        $this->disableCSRFProtection();

        # Бараа
        $products = array('' => '[Сонгох]') + ProductTable::getForSelect();

        $this->setWidgets(array(
            'id' => new sfWidgetFormInputHidden(),
            'product_id' => new sfWidgetFormChoice(array('choices' => $products)),
            'image_name' => new sfWidgetFormInputFile(),
        ));

        $validators = array();
        $validators['product_id'] = new sfValidatorChoice(array('choices' => array_keys($products)),
                        array('invalid' => 'Та жагсаалтанд байгаа бараанаас сонгоно уу'));
        $validators['image_name'] = new sfValidatorFile(array('required' => true, 'mime_types' => 'web_images', 'max_size' => 6144000),
                        array('required' => 'Та зураг оруулна уу', 'mime_types' => 'Та зураг сонгоно уу', 'max_size' => 'Зургийн хэмжээ 6Mb-аас хэтрэхгүй байх ёстой!'));

        $this->setValidators($validators);

        $this->widgetSchema->setNameFormat('photo[%s]');

        # Label
        $this->getWidget('product_id')->setLabel('* Бараа:');
        $this->getWidget('image_name')->setLabel('* Зураг:');
    }

}
